﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;
using System.ServiceModel.DomainServices.Server;
using NetBay.Core.BusinessEntities;
using NetBay.Core.Log;
using Rio.Doc.Business.Repository;
#endregion
namespace Rio.Applications.Web.Services
{
    /// <summary>
    /// Class to handle Business entities in a RIA services
    /// </summary>
    public partial class BusinessEntitiesDomainService : DomainService
    {
        /// <summary>
        /// Retreive all Folders that matches criterias 
        /// </summary>
        /// <param name="p_lOrganisationId">Organisation identifier</param>
        /// <returns></returns>
        [Query]
        public IEnumerable<FolderType> GetFolderTypes(long p_lOrganisationId)
        {
            List<FolderType> l_oFolderTypes = new List<FolderType>(); 

            try
            {
                OrganizationRepository l_oOrganisation;
                GetOrganisationRepository(p_lOrganisationId, out l_oOrganisation);

                // We have finally all FolderTypes owner by the OrganisationID
                l_oFolderTypes = l_oOrganisation.FolderTypesList;
            }
            catch (Exception ex)
            {
                FolderType l_oFolderType = new FolderType("(p_lOrganisationId<" + p_lOrganisationId + ">)", ex);
                NetBay.Core.Log.LogManager.Instance().LogError(l_oFolderType.FullErrorMessage);
                l_oFolderTypes.Add(l_oFolderType);
            }
            return l_oFolderTypes;
        }
    }
}